package test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.concurrent.TimeoutException;

public class Client {

	public static void main(String[] args) throws InterruptedException{
			try {
				Socket socket = new Socket("127.0.0.1",4700);
				OutputStream os=socket.getOutputStream();
				InputStream is=socket.getInputStream();
				byte[] b = new byte[14];
				byte[] gb = new byte[14];
				int count = 0;
				do{
					if(gb[0]==0x00&&count<3){
						os.write(0x01);
						os.flush();
						count++;
					}
					Thread.sleep(3000);
					System.out.println("Client--:"+b[0]);
					System.out.println("Server--:"+gb[0]);
				}while((is.read(gb)!=-1));
				os.close(); //关闭Socket输出流
				is.close(); //关闭Socket输入流
				socket.close(); //关闭Socket
			} catch (Exception e){
				e.printStackTrace();
			}
	}
}
